<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>更改权限数据</title>
  </head>
  <body>
    <div id="updatePermissionPage">
           <div class="form-Container" style="width:620px;float:left;border:1px solid #F0F0F0"">
            <form action="${pageContext.request.contextPath}/permission/editPermission.do"  id="dataForm" class="grayForm" method="post">
                <input type="hidden" name="id" id="id" value="${param.id }"/>
                <input type="hidden" name="uuid" id="uuid" value=""/>
                <input type="hidden" name="parentUUID" id="parentUUID" value="${param.parentUUID }"/>
                <table>
                    <tr>
                        <td ><label for="parentUUID">上级权限:</label></td>
                        <td style="line-height:20px;">
                           <input type="hidden" id="parentUUID" name="parentUUID" value="0" />
                           <input type="text"   id="parentName" name="parentName" readonly="readonly" style="background-color: #F0F0F0">
                        </td>
                        <td ><label for="psmCode">权限编码:</label></td>
                        <td style="line-height:20px;"><input type="text" id="psmCode" required name="psmCode"  /></td>
                    </tr>
                    <tr>
                        <td ><label for="psmName">权限名字:</label></td>
                        <td style="line-height:20px;"><input type="text" id="psmName" required name="psmName"  /></td>
                        <td ><label for="psmUrl">是否显示:</label></td>
                        <td style="line-height:20px;">
                          <input type="radio" id="viewMode"  name="viewMode" checked="checked" value="1"/>是
                          &nbsp; 
                          <input type="radio" id="viewMode"  name="viewMode" value="0"/>否
                        </td>
                    </tr>
                    <tr>
                        <td><label for="orderNo">排序:</label></td>
                        <td style="line-height:20px;" ><input type="text" name="orderNo" id="orderNo"  /></td>
                        <td><label for="showPosition">显示位置:</label></td>
                        <td style="line-height:20px;">
                           <input type="radio"  name="showPosition" checked="checked" value="0"/>常规菜单
                           &nbsp; 
                           <input type="radio"  name="showPosition" value="1"/>主页工具栏
                        </td>
                    </tr>
                    <tr>
                        <td><label for="psmType">链接类型:</label></td>
                        <td style="line-height:20px;" colspan="3">
                           <select name="psmType" style="width:80px;margin-right: 5px">
                             <option value="1" selected="selected">普通链接</option>
                             <option value="2">增加</option>
                             <option value="3">删除</option>
                             <option value="4">修改</option>
                             <option value="5">审批</option>
                             <option value="6">恢复</option>
                             <option value="7">彻底删除</option>
                             <option value="8">文件导入</option>
                          </select>
                        </td>
                    </tr>
                    <tr>
                        <td><label for="psmUrl">访问地址:</label></td>
                        <td colspan="3" style="line-height:20px;"><input type="text" name="psmUrl" id="psmUrl" style="width:462px;" required/></td>
                    </tr>
                    <tr>
                        <td><label for="psmIcon">图标:</label></td>
                        <td colspan="3" style="line-height:20px;"><input type="text" name="psmIcon" id="psmIcon" style="width:462px;" /></td>
                    </tr>
                    
                    <tr>
                        <td><label for="psmDesc">备注:</label></td>
                        <td colspan="3" style="line-height:20px;"><input type="text" name="psmDesc" id="psmDesc" style="width:462px;"/></td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align:center;" >
                            <input type="button" value="提交数据" name="submitData"  />
                            <input type="button" value="关闭" name="close" />
                        </td>
                    </tr>
                </table>
                <div id="confirmMsg"></div>
            </form>
        </div>
        </div>
         <script type="text/javascript">
         var baseId = "#updatePermissionPage ";
        $(document).ready(function () {
        	var id = new Number($(baseId+"input[name='id']").val());
        	var parentUUID = $(baseId+"input[name='parentUUID']").val();
        	var rules = {}
        	var messages = {}
        	messages = {
        			parentName:"请选择左边的父级权限",
        			psmCode:"请输入部门名字",
        			psmName:"请输入权限名字",
        			psmUrl:"访问地址不能为空,如果没有地址请填入#号"
            };
        	
        	var validateForm = $(baseId+"#dataForm").validate({
                debug:true,
                rules:rules,
                messages:messages
            });
        	
        	$("#updatePermissionPage input[name='close']").click(function () {
       		    $("#editDataFormArea").window("close");
       	    })
        	
            //提交数据到服务器
            $(baseId+"input[name='submitData']").click(function () {
            	//提交表单进行验证
            	$(baseId+"#dataForm").submit();
                var validateFlag = validateForm.form();
                var actionUrl = $(baseId+" #dataForm").attr("action");
            	var formData  = $(baseId+" #dataForm").form2Json();
            	if(validateFlag){
            		$.post(actionUrl,{formData:formData},function(data){
            			if(data.code=="00"){
          				  $.messager.confirm('操作确认',data.msg+',请确认是否继续操作？', function(flag){
          					  if(flag){
          						  $("#editDataFormArea").window("close");
          						  tableObject.treegrid('reload',parentUUID);
          					  }
          				  });
          			    }else{
          				   $.messager.alert('操作提示',data.message,'error');
          			    }
            		},"json");
            	}
            });
            
        	if(id>0){
        		//加载表单数据
            	loadFormData(id+"");
        	}
        });
        
        //通过表单加载数据
        function loadFormData(id){
        	$.post(getBasePath()+"permission/getJsonDetail.do",{id:id},function(jsonData){
        		$("#updatePermissionPage #dataForm").form("load",jsonData.data);
  		    },"json");
        }
    </script>
  </body>
</html>
